import React, { FC } from 'react';
import { Form, Select, Input } from 'antd';
import ComponentDemo from '../ComponentDemo/index.jsx';

const { Option } = Select;

interface IProps {
  index: string | number;
}

const Form_Demo: FC<IProps> = ({ index }) => {
  console.log(ComponentDemo);

  return (
    <>
      <Form.Item name={[index, 'select']} label="select">
        <Select>
          <Option value="admin">admin</Option>
          <Option value="Mall">Mall</Option>
        </Select>
      </Form.Item>
      <Form.Item noStyle shouldUpdate>
        {({ getFieldValue }) => {
          console.log(getFieldValue([index, 'select']));

          return (
            getFieldValue([index, 'select']) === 'Mall' && (
              <Form.Item name={[index, 'name']} label="姓名">
                <Input />
              </Form.Item>
            )
          );
        }}
      </Form.Item>
    </>
  );
};

export default Form_Demo;
